package aole;

import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;

public class PlayerMatchInfo {
	private SimpleStringProperty	name;
	private SimpleStringProperty	status;
	private SimpleStringProperty	runsInfo;
	private SimpleDoubleProperty	strikeRate;

	private int						runs, balls;

	public PlayerMatchInfo( String name ) {
		this.name = new SimpleStringProperty( name );
		this.status = new SimpleStringProperty();
		this.runsInfo = new SimpleStringProperty( "0(0)" );
		strikeRate = new SimpleDoubleProperty( 0 );

		runs = 0;
		balls = 0;
	}

	public String getName() {
		return name.get();
	}

	public String getStatus() {
		return status.get();
	}

	public void setStatus( String status ) {
		this.status.set( status );
	}

	public String getRunsInfo() {
		return runsInfo.get();
	}

	public void addRuns( int run ) {
		this.runs += run;
		runsInfo.set( runs + "(" + balls + ")" );
	}

	public void addBalls( int ball ) {
		this.balls += ball;
		runsInfo.set( runs + "(" + balls + ")" );
	}

	public double getStrikeRate() {
		long sr = Math.round( ((double) runs / balls) * 10000.0 );
		return sr / 100.0;
	}
}
